package com.ejuornal.action;

import org.springframework.context.annotation.Scope;

import com.ejuornal.bean.Artical;
import com.ejuornal.bean.Check;
import com.ejuornal.bean.Periodical;
import com.ejuornal.bean.User;
import com.ejuornal.service.ArticalService;
import com.ejuornal.service.CheckService;
import com.ejuornal.service.PeriodicalService;
import com.ejuornal.service.UserService;

@Scope("prototype")
public class ArticalPersonalAction extends BaseAction<Artical> {

	private static final long serialVersionUID = 1L;
	private ArticalService articalService;
	private CheckService checkService;
	private Artical artical;
	private Check check;
	private String articalId;
	private String status;
	private Periodical periodical;
	private PeriodicalService periodicalService;
	private User user;
	private UserService userService;

	public String add(){
		int userId = super.getUserIdBySession();
		artical.setUserId(userId);
		artical.setStatus("4");
		articalService.add(artical);
		
		return SUCCESS;
	}
	
	public String findMyArtical(){
		int userId = super.getUserIdBySession();
		String url = "artical/artical_findMyArtical?userId=" + userId + "&status=" + status + "&";
		//3 代表通过
		if ("3".equals(status)) {
			pages = articalService.findMyArtical((page-1)*10, url, userId, status);
			return "passArtical";
		} else if("2".equals(status)){	//2 代表退稿
			pages = articalService.findMyArtical((page-1)*10, url, userId, status);
			return "unPassArtical";
		} else if("1".equals(status)){	// 正在审核中
			pages = articalService.findCheckingArtical((page-1)*10, url, userId);
			return "checkingArtical";
		} else {
			return "error";
		}
	}
	/**
	 * 主编审核文章时查看文章信息及编委审核建议
	 * @return
	 */
	public String findSuggestion(){
		check = checkService.findSuggestion(Integer.parseInt(articalId));
		artical = articalService.findById(Integer.parseInt(articalId));
		periodical = periodicalService.findPeriodicalByArticalId(Integer.parseInt(articalId));
		user = userService.getUser(Integer.parseInt(articalId));
		
		return SUCCESS;
	}
	
	public Check getCheck() {
		return check;
	}
	public void setCheck(Check check) {
		this.check = check;
	}
	public String getArticalId() {
		return articalId;
	}
	public void setArticalId(String articalId) {
		this.articalId = articalId;
	}
	
	public CheckService getCheckService() {
		return checkService;
	}
	public void setCheckService(CheckService checkService) {
		this.checkService = checkService;
	}
	
	public ArticalService getArticalService() {
		return articalService;
	}
	public void setArticalService(ArticalService articalService) {
		this.articalService = articalService;
	}
	public Artical getArtical() {
		return artical;
	}
	public void setArtical(Artical artical) {
		this.artical = artical;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Periodical getPeriodical() {
		return periodical;
	}

	public void setPeriodical(Periodical periodical) {
		this.periodical = periodical;
	}

	public PeriodicalService getPeriodicalService() {
		return periodicalService;
	}

	public void setPeriodicalService(PeriodicalService periodicalService) {
		this.periodicalService = periodicalService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
}
